/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package neuronalenetzeelearning.view.controlpanel;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import neuronalenetzeelearning.model.Graph;
import neuronalenetzeelearning.view.help.HelpPanel;
import neuronalenetzeelearning.view.help.HelpWindowFactory;

/**
 *
 * @author Henning
 */
public class LearningRuleChooserPanel extends GraphPanelProperty {

    JComboBox learningRuleChooser;

    public LearningRuleChooserPanel() {

        super();
        this.setBackground(background);
        this.setLayout(grid);

        this.setBorder(javax.swing.BorderFactory.createTitledBorder("Bitte wählen Sie die Lernregel aus!"));

        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.gridheight = 1;
        constraints.gridx = 1;
        constraints.gridy = 1;

        JLabel bord = new JLabel("------------------------------------------------------------------------------------------------------------------");
        add(bord, constraints);

        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.gridwidth = 4;
        constraints.gridheight = 1;
        constraints.gridx = 1;
        constraints.gridy = 2;
        constraints.insets = new Insets(1, 1, 1, 1);

        learningRuleChooser = new JComboBox();
        learningRuleChooser.setModel(new DefaultComboBoxModel(new String[]{"Hebbsche Lernregel", "Überwachtes Lernen"}));
        add(learningRuleChooser, constraints);

        constraints.gridwidth = GridBagConstraints.RELATIVE;
        constraints.fill = GridBagConstraints.HORIZONTAL;

        navigation.add(previous, constraints);
        navigation.add(getHelpButton(), constraints);
        navigation.add(next, constraints);

        constraints.gridwidth = GridBagConstraints.REMAINDER;
        constraints.gridx = 1;
        constraints.gridy = 3;

        add(navigation, constraints);

        setVisible(true);
    }

    public int getLearningRule() {
        return this.learningRuleChooser.getSelectedIndex();
    }

    @Override
    public void setGraph(Graph graph) {
        this.graph = graph;
    }

    @Override
    public void writePropertysToFile(String prop) {
        super.propertys.add(prop);
    }

    @Override
    public LinkedList<String> getPropertys() {
        return super.propertys;
    }

    public static void main(String[] args) {
        JFrame test = new JFrame();
        Dimension size = new Dimension();
        size.setSize(800, 800);
        test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        test.setPreferredSize(size);
        Graph graph = new Graph();
        test.add(new LearningRuleChooserPanel());

        test.setResizable(false);
        test.pack();
        test.setVisible(true);
    }

    @Override
    public ActionListener getActionListener() {
        return new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                HelpWindowFactory.createHelpWindow(new HelpPanel("src/neuronalenetzeelearning/view/help/resources/Lernregel aussuchen.png"));
            }
        };

    }
}
